<template>
  <div>
    <el-form label-width="120px" label-position="left" :model="searchForm">
      <el-row>
        <el-col :span="8">
          <el-form-item label="角色名字">
            <el-input v-model="searchForm.name"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="角色描述">
            <el-input v-model="searchForm.description"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="创建时间">
            <el-date-picker
              v-model="searchForm.createTime"
              type="daterange"
              range-separator="至"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
            >
            </el-date-picker>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="8">
          <el-form-item label="学区房用户">
            <el-select v-model="searchForm.isSchool">
              <el-option label="全部" :value="''"></el-option>
              <el-option label="是" :value="1"></el-option>
              <el-option label="否" :value="0"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-button @click="onSearch" type="primary">查 询</el-button>
          <el-button @click="reset()">重 置</el-button>
        </el-col>
      </el-row>
    </el-form>
    <hr />
    <el-button type="primary" @click="toAdd">新 增</el-button>
    <page-table
      :data="tableData"
      :total="count"
      :page="pageIndex"
      :pageSize="pageSize"
      ref="pageTable"
      showIndex
      @currentChange="currentChange"
      @sizeChange="sizeChange"
      :loading="loading"
    >
      <el-table-column
        prop="name"
        label="角色名"
        show-overflow-tooltip
      ></el-table-column>
      <el-table-column label="创建时间" show-overflow-tooltip>
        <template slot-scope="{ row }">
          {{ row.createdAt | timeFilter }}
        </template>
      </el-table-column>
      <el-table-column label="是否是学区房用户" show-overflow-tooltip>
        <template slot-scope="{ row }">
          <span>{{ !!row.isSchool ? "是" : "否" }}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作">
        <template slot-scope="{ row }">
          <el-button type="text" @click="toRemove(row.id)">删除</el-button>
          <el-button type="text" @click="toEdit(row.id)">修改</el-button>
          <el-button type="text" @click="toDetail(row.id)">详情</el-button>
        </template>
      </el-table-column>
    </page-table>
    <post-dialog @cancel="cancel" :dialogVisible="dialogVisible" :opId="opId" />
    <detail-dialog
      @cancel="cancel1"
      :dialogVisible="dialogVisible1"
      :opId="opId"
    />
  </div>
</template>

<script>
import initData from "../../../mixins/initData";
import PostDialog from "../components/postDialog";
import DetailDialog from "../components/detailDialog";
export default {
  components: { DetailDialog, PostDialog },
  name: "roleManage",
  mixins: [initData],
  data() {
    return {
      getUrl: "/api/role/role",
      searchForm: {
        name: "",
        isSchool: "",
        description: "",
        createTime: ""
      }
    };
  }
};
</script>

<style scoped></style>
